//
//  PageViewController.h
//  ActiveDeck
//
//  Created by Chiao-Wei Liu on 2011/2/10.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "GDataXMLNode.h"
#import <MediaPlayer/MediaPlayer.h>
#import "AD_Kiosk.h"
#import "AD_Button.h"
#import "InstantFeedbackController.h"
#import "ContainerView.h"
#import "UpContainerView.h"
#import "AD_ContainerOB.h"
#import "CustomMovieViewController.h"
#import "WebViewController.h"
#import "AD_Action.h"
#import "Actions.h"

enum {
    UIViewAnimationDirectionForward          = 1 <<  0,
    UIViewAnimationDirectionReverse          = 1 <<  1
};
typedef NSUInteger UIViewAnimationDirection;


@class AD_Page;

@interface PageViewController : UIViewController <UIScrollViewDelegate, UITextViewDelegate> {
	int PID;
	int SlideID;
	int PageCount;
	AD_Page *pageOB;
    AD_Kiosk *Kiosk;
	GDataXMLElement *userData;
    NSMutableArray *LABTlinkSets;
    MPMoviePlayerController *mp;
	
    BOOL Show;
    
    int numberCorrect;
    int numberIncorrect;
    
    int SlideIndex;
    int SlideCount;
    int EditIndex;
    
	id _delegate;
    NSString *PresentName;
    
    InstantFeedbackController *feedbackVC;
    UpContainerView *Bar_UpperContainer;
    AD_ContainerOB *containOB;
    ContainerView *Bar_Container;
    
    IBOutlet UIScrollView *Vw_AddNote;
    IBOutlet UIScrollView *Vw_AddPhotoNote;
    IBOutlet UIImageView *SavedImage;
    
    IBOutlet UIImageView *noteWarning;
    IBOutlet UIImageView *photoNoteWarning;
    
    BOOL isEditingNote;
    
    BOOL isForPDF;
    BOOL canExportToPDF;
    
    double oldWidth;
    double oldX;
    double oldY;
    
    double hOffset;
    double vOffset;
    
    BOOL canNavigateForwards;
    BOOL canNavigateBackwards;
}
@property (readwrite) double oldX;
@property (readwrite) double oldY;
@property (readwrite) double oldWidth;
@property (readwrite) double hOffset;
@property (readwrite) double vOffset;
@property (nonatomic, retain) UIImageView *SavedImage;
@property (nonatomic, retain) UIScrollView *Vw_AddNote;
@property (nonatomic, retain) UIScrollView *Vw_AddPhotoNote;
@property (nonatomic, retain) UIImageView *noteWarning;
@property (nonatomic, retain) UIImageView *photoNoteWarning;
@property (readwrite) int EditIndex;
@property (readwrite) int SlideIndex;
@property (readwrite) int SlideCount;
@property (nonatomic, retain) ContainerView *Bar_Container;
@property (nonatomic, retain) AD_ContainerOB *containOB;
@property (nonatomic, retain) UpContainerView *Bar_UpperContainer;
@property (nonatomic, retain) InstantFeedbackController *feedbackVC;
@property (nonatomic, retain) MPMoviePlayerController *mp;

@property (nonatomic, retain) NSMutableArray *LABTLinkSets;
@property (nonatomic, retain) AD_Kiosk *Kiosk;
@property (nonatomic, retain) NSString *PresentName;
@property (readwrite) int PageCount;
@property (readwrite) int PID;
@property (readwrite) int SlideID;
@property (readwrite) BOOL Show;
@property (readwrite) int numberCorrect;
@property (readwrite) int numberIncorrect;
@property (nonatomic, retain) GDataXMLElement *userData;
@property (nonatomic, retain) AD_Page *pageOB;
@property (readwrite) BOOL isEditingNote;
@property (readwrite) BOOL isForPDF;
@property (readwrite) BOOL canExportToPDF;
@property (readwrite) BOOL canNavigateForwards;
@property (readwrite) BOOL canNavigateBackwards;

-(void) leavePresent;
-(void)buttonAction:(AD_Button*)multiButton;
-(void)userActivate;
-(void) loadPrePage;
-(void) loadPrePage;
-(void) loadNextPage;
-(void) transitionWithView:(UIView *)firstView direction:(UIViewAnimationDirection)direction;
-(void) transitionWithView:(UIView *)firstView direction:(UIViewAnimationDirection)direction doTransition:(BOOL)shouldAnimate;

-(void) disMiss;
-(void) submitUserData;
-(void) appendUserData:(GDataXMLElement *)userDataNode;
-(void) addInstantFeedback;
-(void)showSuperBar;

-(id)delegate;
-(void)setDelegate:(id)delegate;

-(void)GoToSection:(int)NewSectionID
         NewPageID:(int)NewPageID;
-(void)ResetIdleTimer;
-(void)addImage;

-(void)layButtonPress:(id)sender;
-(void)AutoHidePress:(id)sender;
-(void)AddLayer;
-(void)SetLayerAlpha:(int)alphaValue
             setView:(UIView*)setView;

-(void)windowClosed;
-(void)showNextPage;
-(void)SaveIntoFile;
-(void)AddNote;

-(IBAction)RemoveAddNote;
-(IBAction)SaveNote;
-(IBAction)SavePhotoNote;
- (void)ShowMoreContainer;
-(void)UserCamera;
-(void)AddPhotoNote;
- (void)MaxContainer;
-(void)notifySlideChange;
-(void)enableOtherButtons: (Action_Layer*)layer :(BOOL)enable;
-(BOOL)setCondition: (NSArray*)condition;
@end

@interface NSObject(PageSubmitDelegate)
-(void)changePage:(int)pageIndex 
        direction:(UIViewAnimationDirection)direction;
-(void)leavePresentation;
-(void)LeaveSection:(int)NewSectionID
          NewPageID:(int)NewPageID;
-(void)idleReset;
- (void)updateSubmitStatus;
-(void)updateCorrectAnswers:(int)numCorrect:(int)numIncorrect;
- (void)SaveIntoFile;
- (void)ShowCamera:(PageViewController *)sender;
- (void)exportPDF;
- (void)navigateBackwards;
- (void)updateSecondaryChannelID:(int)key;
@end

@interface NSObject(NoteDelegate)
-(void)setUpdateStatus:(BOOL)shouldUpdate:(PageViewController*)sender;
@end



